package com.yh.serivicelmpl;

import com.yh.dao.AdminDao;
import com.yh.dao.StudentDao;
import com.yh.dao.TeacherDao;
import com.yh.daoimpl.AdminDaoImpl;
import com.yh.daoimpl.StudentDaoImpl;
import com.yh.daoimpl.TeacherDaoImpl;
import com.yh.javabean.Admin;
import com.yh.javabean.Student;
import com.yh.javabean.Teacher;
import com.yh.serivice.MainService;

import java.util.ArrayList;

/**
 * @Auther: Liang
 * @Date: 2024/4/2 - 04 - 02 - 10:25
 * @Description: com.sms.serviceimpl
 * @version: 1.0
 */
public class MainServiceImpl implements MainService {
    StudentDao studentDao = new StudentDaoImpl();
    TeacherDao teacherDao = new TeacherDaoImpl();
    AdminDao adminDao = new AdminDaoImpl();

    @Override
    public Student studentLogin(String username, String password) {
        ArrayList<Student> students = studentDao.selectByUsernameAndPassword(username, password);
        if (students.isEmpty()) {
            return null;
        } else {
            return students.get(0);
        }
    }

    @Override
    public Teacher teacherLogin(String username, String password) {
        ArrayList<Teacher> teachers = teacherDao.selectByUsernameAndPassword(username, password);
        if (teachers.isEmpty()) {
            return null;
        } else {
            return teachers.get(0);
        }
    }

    @Override
    public Admin adminLogin(String username, String password) {
        ArrayList<Admin> admins = adminDao.selectByUsernameAndPassword(username, password);
        if (admins.isEmpty()) {
            return null;
        } else {
            return admins.get(0);
        }


    }
}
